package org.dim.oa.utils;

import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
import java.util.Date;


@Slf4j
public class DateUtil {

    public static final String YYYYMMDD = "yyyy-MM-dd";
    public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";

    public static String formatDatetoString(Date date, String pattern) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        return  simpleDateFormat.format(date);
    }

    public static String getTimeStamp(String fileName) {

        String preFileName = FileUtil.getFilenamePrefix1(fileName);
        String suffixFileName = FileUtil.getFilenameSuffiox1(fileName);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(YYYYMMDDHHMMSS);
        return  preFileName +"_"+ simpleDateFormat.format(new Date()) +"."+ suffixFileName;
    }

    public static void main(String[] args) {
        String timeStamp = getTimeStamp("haha.haha.hahha.text");
        log.info(timeStamp);
        log.info(getTimeStamp("haha.haha.hahha.text"));
        log.info(formatDatetoString(new Date(), "yyyy-MM-dd HH:mm:ss"));
    }
}
